*_____________________________________________________
* Table SI2: GMM Results
*_____________________________________________________

version // my version is 17
clear


*_____________________________________________________
* LOAD AND CLEAN THE DATA
*_____________________________________________________

* Set the working directory
* USER WILL NEED TO CHANGE THE WORKING DIRECTORY
cd "~/Desktop/replication_women_exchange" 

* Load the data
import delimited "05_data_women_exchange_tscs_replication.csv"

* Destring the variables
quietly{
destring log_wdi_overvalued - dvdem_elec_dem, force replace 
}

* Describe the data set
describe

* Tsset the data
tsset cowcode year

* Lable variables
label var flfp "Female Labor Force Participation"
label var flfplag "L.FLFP"
label var dflfplag "D.L.FLFP"
label var flfp_mlfplag  "L.Labor Force Ratio"
label var dflfp_mlfplag "D.L.Labor force Ratio"
label var log_wdi_overvalued  "logOvervalued"
label var log_wdi_overvaluedlag "L.logOvervalued"
label var log_gdpcap  "Per Capita GDP"
label var log_gdpcaplag "L.Per Capita GDP"
label var sqlog_gdpcap  "Squared Per Capita GDP"
label var sqlog_gdpcaplag "L.Squared Per Capita GDP"
label var log_oilgascap "Per Capita Resource Rents"
label var log_oilgascaplag "L.Per Capita Resource Rents"



* Arellano-Bond with forward orthogonal deviations instead of differences
* (so as to not magnify the effects of gaps in the panel). 
* FLFP is presumed predetermined (to reduce Nickell bias) and 
* REER is presumed endogenous. Use PCA to reduce the problem of 
* too many instruments 

**# Table SI2: Model 1: GMM: FLFP ~ REER
xtabond2 									 ///
	flfp 									 /// The model
	flfplag dflfplag 						 ///
	log_wdi_overvalued log_wdi_overvaluedlag ///
	log_gdpcap log_gdpcaplag 				 ///
	sqlog_gdpcap sqlog_gdpcaplag 			 ///
	log_oilgascap log_oilgascaplag 			 ///
	if oecd == 0 & country != "Zimbabwe", 	 ///
	gmmstyle( 								 /// Endogenous Xs
		L.flfp  							 ///
		L.log_wdi_overvalued, 				 ///
		lag(.  .)   						 ///
	) 										 ///
	ivstyle( 								 /// Exogenous Xs
		L(0/1).log_gdpcap 					 ///
		L(0/1).sqlog_gdpcap  				 ///
		L(0/1).log_oilgascap , 				 /// 
	) 										 ///
	nolevel 								 /// Difference GMM
	twostep 								 /// Two step estimator
	pca     								 /// use PCA to reduce the number of instruments
	cluster(cowcode)

estimates store gmm_flfp_base

**# Table SI2: Model 2: GMM: Ratio ~ REER 
xtabond2 									 ///
	flfp_mlfp								 /// The model
	flfp_mlfplag dflfp_mlfplag				 ///
	log_wdi_overvalued log_wdi_overvaluedlag ///
	log_gdpcap log_gdpcaplag 				 ///
	sqlog_gdpcap sqlog_gdpcaplag 			 ///
	log_oilgascap log_oilgascaplag 			 ///
	if oecd == 0 & country != "Zimbabwe", 	 ///
	gmmstyle( 								 /// Endogenous Xs
		L.flfp_mlfp							 ///
		L.log_wdi_overvalued, 				 ///
		lag(.  .)   						 ///
	) 										 ///
	ivstyle( 								 /// Exogenous Xs
		L(0/1).log_gdpcap 					 ///
		L(0/1).sqlog_gdpcap  				 ///
		L(0/1).log_oilgascap , 				 /// 
	) 										 ///
	nolevel 								 /// Difference GMM
	twostep 								 /// Two step estimator
	pca     								 /// use PCA to reduce the number of instruments
	cluster(cowcode)

estimates store gmm_ratio_base 

**# Table SI2: Make table
esttab 				 						 ///
	gmm_flfp_base							 ///
	gmm_ratio_base,							 ///
	b(2) se(2) 								 ///
	label varwidth(20) 						 ///
	title(									 ///
		Generalized Methods of Moments 		 ///
		Results of the Effect of REER		 ///	
	) 										 ///
	mgroups("FLFP" "Labor Force Ratio", 	 /// 
	pattern(1 0 1 0)) 						 ///
	nomtitle 								 ///
	star(* 0.1 ** 0.05 *** 0.01) 			 /// 
	legend 									

